home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / scanner / examples / autodoc / autodoc.c next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  1.4 KB  |  66 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Scan handler looking for Autodoc nodes. This handler simply looks for
  4.   formfeeds and therefore won't work with all Autodocs (Commodore's Autodocs
  5.   are handled properly).
  6.  
  7.   Scan handlers are plain functions (loadSeg()'ed): no standard C startup
  8.   code and no library calls permitted. We have to put string constants into
  9.   the code segment (DICE compiler: option -ms1).
  10.   
  11.   DICE:
  12.  
  13.   dcc autodoc.c -// -l0 -md -mRR -o golded:etc/scanner/autodoc
  14.  
  15.   ------------------------------------------------------------------------------
  16. */
  17.  
  18. #include <exec/types.h>
  19.  
  20. #define FORMFEED 12
  21.  
  22. ULONG
  23. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  24. {
  25.     // look for node header
  26.  
  27.     const char *version = "$VER: ADoc 1.4 (" __COMMODORE_DATE__ ")";
  28.  
  29.     if (**text == FORMFEED) {
  30.  
  31.         // look for beginning of header string (e.g. "Dos.Library/Open")
  32.  
  33.         while (len && (**text <= ' ')) {
  34.  
  35.             ++*text;
  36.             --len;
  37.         }
  38.  
  39.         // ignore first part of header string
  40.  
  41.         while (len && (**text != '/')) {
  42.  
  43.             ++*text;
  44.             len--;
  45.         }
  46.  
  47.         // extract node name
  48.  
  49.         if (len) {
  50.  
  51.             UWORD letters;
  52.  
  53.             ++*text;
  54.             --len;
  55.  
  56.             for (letters = 0; len && ((*text)[letters] >= 32); --len)
  57.  
  58.                 ++letters;
  59.  
  60.             return(letters);
  61.         }
  62.     }
  63.  
  64.     return(FALSE);
  65. }
  66.